package com.example.guance_demo_emqx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;

@RestController
@SpringBootApplication
public class GuanceDemoEmqxApplication {

	public static void main(String[] args) {
		SpringApplication.run(GuanceDemoEmqxApplication.class, args);
	}

	@Autowired
	private MqttClientService mqttClientService;

	@PostMapping("/publish")
	public String publishMessage(@RequestParam String topic, @RequestParam String message) {
		mqttClientService.publishMessage(topic, message);
		return "Message published successfully\n";
	}
}
